package club.vann.kafka.mock.util;

import com.cyberx.lunyu.AcceptorOuterClass;
import java.util.Map;
import java.util.UUID;

public class AcceptorUtil {
  private AcceptorUtil() {}

  public static AcceptorOuterClass.Acceptor.AcceptorResponse ofResponse(
      String clientRequestId,
      AcceptorOuterClass.Acceptor.Status status,
      String responseTopic,
      String errMsg,
      Map<String, String> dataMap) {
    return AcceptorOuterClass.Acceptor.AcceptorResponse.newBuilder()
        .setStatus(status)
        .setRequestId(UUID.randomUUID().toString())
        .setResponseId(UUID.randomUUID().toString())
        .setClientRequestId(clientRequestId)
        .setTopic(responseTopic)
        .setTimestamp(System.currentTimeMillis())
        .setErrMsg(errMsg)
        .putAllData(dataMap)
        .build();
  }
}
